package com.yylending.las.lending.process.chooseamount;

import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yyfax.infrastructure.network.entity.EmptyEntity;
import com.yylending.las.Global;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

/**
 * Created by fan on 2017/6/28.
 * Copyright  2017 www.yylending.com. All Rights Reserved.
 */
public class ChooseAmountModel extends Model {

	@Override
	public Observable getObservable(Object params, int functionalCode) {
		Service service = (Service) NetworkHelper.createService(Service.class);
		return service.getRate(Global.LOGIN_TOKEN, new EmptyEntity());

	}

	@Override
	public void onNext(Object entity) {
		GetRateResult getRateResult = cast(entity);
		EventAgent.post(getRateResult);

	}

	private interface Service {
		@POST("server/loan/getRate")
		Observable<GetRateResult> getRate(@Header("token") String token, @Body EmptyEntity params);
	}

	static class GetRateResult extends BaseResultEntity<Rate> {
	}

	public static class Rate {
		/**
		 * 产品利率
		 */
		public String businessRate = "";
		/**
		 * 综合费率
		 */
		public String integratedRate = "";
		/**
		 * 一次性费率
		 */
		public String onceFeeRate = "";
	}
}
